<template>
  <div class="container">
    <el-form>
      <el-row :gutter="3" class="cust-r-title">
        <el-col :span="3">
          <p class="cust-r-l">账户关系管理</p>
        </el-col>
        <el-col :span="6" :offset="15">
          <el-button class="cust-r-c" @click="digShow"
            >+&nbsp;&nbsp;增加映射关系</el-button
          >
           <el-button class="cust-r-r" @click="syncCustPro">自动同步集团账户到省</el-button>
        </el-col>
      </el-row>
    </el-form>
    <pro-select-city
      :tableCol="tableCol1"
      :queryData="queryData"
      @getCustList="getCustList"
    ></pro-select-city>
    <el-table
      ref="custArr"
      :data="custArr"
      border
      stripe
      :header-cell-style="{
        background: '#F2F2F2',
        color: '#333',
      }"
      tooltip-effect="dark"
      style="width: 100%"
    >
      <el-table-column label="序号" type="index" align="center">
      </el-table-column>
      <el-table-column
        prop="provinceName"
        label="省份"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="lanName"
        label="地市"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="oldPartyCode"
        label="集团客户编码"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="provinceAccountId"
        label="省账户ID"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="provinceAccountNumber"
        label="省账户编码"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="createDate"
        label="创建时间"
        show-overflow-tooltip
        align="center"
      >
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button
            class="editBtn"
            @click="handleClick(scope.row)"
            type="text"
            size="small"
            >修改</el-button
          >
          <el-button
            class="delBtn"
            type="text"
            size="small"
            @click="delectClick(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      @current-change="pageHandleCurrentChange"
      :current-page="parseInt(tablePage.pageIndex)"
      :page-size="parseInt(tablePage.pageSize)"
      layout="total, prev, pager, next, jumper"
      :total="parseInt(tablePage.rowCount)"
      class="m-pagination"
    >
    </el-pagination>
    <div class="btnBox">
      <el-button type="primary" class="returnBtn" @click="returnClick">
        返回
      </el-button>
    </div>
    <el-dialog
      ref="addcustmer"
      title="新建关系"
      width="80%"
      :visible.sync="outerVisible"
      :close-on-click-modal="false"
      :withHeader="false"
      class="m-dialog"
      @close="closeShow"
    >
      <el-dialog
        width="80%"
        title="查询省账户"
        :visible.sync="innerVisible"
        append-to-body
      >
        <el-form :label-position="labelPosition" label-width="80px">
          <el-row :gutter="3" class="m-contain">
            <el-col :span="5" :offset="1">
              <el-form-item label="客户名称:" class="u-ipt">
                <el-input
                  placeholder="请输入内容"
                  v-model="getProData.custName"
                  class="input-with-select"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="客户编码:" class="u-ipt">
                <el-input
                  placeholder="请输入内容"
                  v-model="getProData.custCode"
                  class="input-with-select"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="省账户ID:" class="u-ipt">
                <el-input
                  placeholder="请输入内容"
                  v-model="getProData.proAId"
                  class="input-with-select"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="省客户ID:" class="u-ipt">
                <el-input
                  placeholder="请输入内容"
                  v-model="getProData.proId"
                  class="input-with-select"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="3">
              <el-button class="checkBtn" @click="checkProAcc"> 查询 </el-button>
            </el-col>
             <el-col :span="5" :offset="1">
              <el-form-item label="省账户编码:" class="u-ipt">
                <el-input
                  placeholder="请输入内容"
                  v-model="getProData.proAccCode"
                  class="input-with-select"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="证件类型:" class="u-ipt">
                <el-select
                  @change="ChangeIdCard"
                  v-model="getProData.idType"
                  placeholder="请选择"
                  class="m-select"
                >
                  <el-option
                    v-for="item in idCardList"
                    :key="item.code"
                    :label="item.name"
                    :value="item.code"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="证件号码:" class="u-ipt">
                <el-input
                  placeholder="请输入内容"
                  v-model="getProData.idNum"
                  class="input-with-select"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="5">
              <el-form-item label="省接入号码:" class="u-ipt">
                <el-input
                  placeholder="请输入内容"
                  v-model="getProData.proInNum"
                  class="input-with-select"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <el-table
          ref="proList"
          :data="proList.slice(
            (proTablePage.pageIndex - 1) * proTablePage.pageSize,
            proTablePage.pageIndex * proTablePage.pageSize
          )"
          border
          stripe
          :header-cell-style="{
            background: '#F2F2F2',
            color: '#333',
          }"
          tooltip-effect="dark"
          style="width: 100%"
          @row-click="chooseProAcc"
        >
          <el-table-column
            prop="REGION_NAME"
            label="地市"
            show-overflow-tooltip
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="PROVINCE_ACCOUNT_NANE"
            label="账户名称"
            show-overflow-tooltip
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="PROVINCE_ACCOUNT_NUMBER"
            label="省账户编码"
            show-overflow-tooltip
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="PROVINCE_ACCOUNT_ID"
            label="省账户ID"
            show-overflow-tooltip
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="PROVINCE_CUST_ID"
            label="省客户ID"
            show-overflow-tooltip
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="STATUS_DATE"
            label="创建时间"
            show-overflow-tooltip
            align="center"
          >
          </el-table-column>
        </el-table>
        <el-pagination
          background
          @current-change="proPageChange"
          :current-page="parseInt(proTablePage.pageIndex)"
          :page-size="parseInt(proTablePage.pageSize)"
          layout="total, prev, pager, next, jumper"
          :total="parseInt(proTablePage.rowCount)"
          class="m-pagination"
        >
        </el-pagination>
      </el-dialog>
      <pro-select-city
        ref="ProSelectCity"
        btnText="查询省内接口"
        :tableCol="tableCol2"
        :queryData="queryData1"
        @innerDigShow="innerDigShow"
      ></pro-select-city>
      <div class="btnBox">
        <el-button type="primary" class="confirmBtn" @click="addCust"
          >确定</el-button
        >
        <el-button type="info" class="returnBtn" @click="closeShow"
          >取消</el-button
        >
      </div>
    </el-dialog>
    <el-dialog
      width="70%"
      title="修改关系"
      :close-on-click-modal="false"
      :visible.sync="changeVisible"
      append-to-body
    >
      <el-dialog
        width="70%"
        title="查询集团账户"
        :visible.sync="changeInnerVisible"
        append-to-body
      >
        <el-form label-width="100px">
          <el-row :gutter="3" class="m-contain">
            <el-col :span="7" :offset="3">
              <el-form-item label="账户编码" class="u-ipt">
                <el-input
                  placeholder="请输入账户编码"
                  v-model="getJtData.accCode"
                  class="input-with-select"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="账户名称" class="u-ipt">
                <el-input
                  placeholder="请输入账户名称"
                  v-model="getJtData.accName"
                  class="input-with-select"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="2">
              <el-button class="checkBtn" @click="checkBtn"> 查询 </el-button>
            </el-col>
          </el-row>
        </el-form>
        <el-table
          ref="proCustArr"
          :data="jtList"
          border
          stripe
          :header-cell-style="{
            background: '#F2F2F2',
            color: '#333',
          }"
          tooltip-effect="dark"
          style="width: 100%"
          @row-click="chooseJtCust"
        >
          <el-table-column
            prop="acctCd"
            label="账户编码"
            show-overflow-tooltip
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="acctName"
            label="账户名称"
            show-overflow-tooltip
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="custName"
            label="客户名称"
            show-overflow-tooltip
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="ifDefault"
            label="是否默认账户"
            show-overflow-tooltip
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="createDate"
            label="创建时间"
            show-overflow-tooltip
            align="center"
          >
          </el-table-column>
        </el-table>
        <el-pagination
          background
          @current-change="jtPageChange"
          :current-page="parseInt(jtTablePage.pageIndex)"
          :page-size="parseInt(jtTablePage.pageSize)"
          layout="total, prev, pager, next, jumper"
          :total="parseInt(jtTablePage.rowCount)"
          class="m-pagination"
        >
        </el-pagination>
      </el-dialog>
      <el-form label-width="80px">
        <el-row :gutter="3" class="m-contain">
          <el-col :span="7">
            <el-form-item label="省份" class="u-ipt jt-ipt" required>
              <el-select
                v-model="changeRowInfo.provinceName"
                class="m-select"
                disabled
              >
                <el-option value=""> </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="地市" class="u-ipt jt-ipt" required>
              <el-select
                v-model="changeRowInfo.lanName"
                placeholder="请选择"
                class="m-select"
                disabled
              >
                <el-option value=""> </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="省客户ID" class="u-ipt jt-ipt" required>
              <el-input
                v-model="changeRowInfo.provinceCustId"
                class="input-with-select jtInput"
                disabled
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-button class="checkBtn" @click="checkCustBtn">
              查询集团账户
            </el-button>
          </el-col>
          <el-col :span="7">
            <el-form-item label="省账户ID" class="u-ipt jt-ipt" required>
              <el-input
                v-model="changeRowInfo.provinceAccountId"
                class="input-with-select jtInput"
                disabled
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="集团客户编码" class="u-ipt jt-ipt" required>
              <el-input
                v-model="changeRowInfo.oldPartyCode"
                class="input-with-select jtInput"
                disabled
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="集团账户编码" class="u-ipt jt-ipt" required>
              <el-input
                v-model="changeRowInfo.acctCd"
                class="input-with-select jtInput"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="btnBox">
        <el-button type="primary" class="confirmBtn" @click="jtCustBtn"
          >确定</el-button
        >
        <el-button type="info" class="returnBtn" @click="closeShow"
          >取消</el-button
        >
      </div>
    </el-dialog>
    <el-dialog
      width="60%"
      title="自动同步账户"
      :close-on-click-modal="false"
      :visible.sync="syncVisible"
      append-to-body
    >
      <pro-select-city
        ref="ProSelectCity"
        :tableCol="proCityForm"
        @getCustList="getCustList"
        :queryData="queryData2"
      ></pro-select-city>
      <div class="btnBox">
        <el-button type="primary" class="confirmBtn" @click="accAutoSynch"
          >确定</el-button
        >
        <el-button type="info" class="returnBtn" @click="closeShow"
          >取消</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import CreateNewAccountManager from "@/api/customer/CreateNewAccountManager";
import ProSelectCity from "@/views/customer/components/proSelectCity";
export default {
  data() {
    return {
      custArr: [], //查询的数据
      proCustArr: [], //省客户查询的数据
      labelPosition: "left",
      queryData: {
        proSelect: "", //选择的省
        citySelect: "", //选择的城市
        proId: "", //省客户id
        proAId:"",//省账户id
      },//查询列表
      queryData1: {
        proSelect: "", //选择的省
        citySelect: "", //选择的城市
        proId: "", //省客户id
        proAId:"",//省账户id
        provinceAccountNumber:''
      },//添加映射关系
      queryData2: {
        proSelect: "", //选择的省
        citySelect: "", //选择的城市
        proId: "", //省客户id
        proAId:"",//省账户id
      },//修改集团关系
      tableCol1: {
        col: [6, 6, 0, 5],
        offset: 2,
        label: "省账户ID",
        custIsShow: false,
        amountIsShow: true,
        checkShow:true
      },
      tableCol2: {
        col: [5, 5, 5, 5],
        offset: 0,
        label: "省账户ID",
        custIsShow: true,
        amountIsShow: true,
        checkShow:true
      },
      //同步到省组件传值
      proCityForm: {
        col: [10, 11, 0, 0],
        offset: 3,
        label: "",
        custIsShow: true,
        amountIsShow: false,
        checkShow:false
      },
      tablePage: {
        pageIndex: 1, //当前页码
        pageSize: 5, //每页多少条
        rowCount: 10, //总条数
      }, //查询列表分页
      proTablePage: {
        pageIndex: 1, //当前页码
        pageSize: 5, //每页多少条
        rowCount: 0, //总条数
      }, //省客户查询列表
      jtTablePage: {
        pageIndex: 1, //当前页码
        pageSize: 5, //每页多少条
        rowCount: 10, //总条数
      }, //集团查询列表分页
      getProData: {
        custName: "",
        custCode:"",
        proId: "",
        proAId: "",
        proAccCode:"",
        idType: "",
        idNum: "",
        proInNum: "",
      }, //查询省客户列表
      getJtData: {
        accCode:'',
        accName:''
      }, //查询集团客户列表
      proList: [], //查询到省客户列表的数据
      jtList: [
      ], //查询到的集团客户列表数据
      outerVisible: false,
      innerVisible: false,
      changeVisible: false, //修改关系弹窗显示按钮
      changeInnerVisible: false, //修改关系内弹窗
      syncVisible:false,//同步账户到省弹窗
      proSelectVal: "", //子组件传过来的省id，用于查询省客户列表
      idCardList: [], //证件类型列表
      changeRowInfo: {}, //修改当前行的信息
      acctCdOld: "", //老的账户编码
      jtCustNumberOld: "", //老的集团客户编码
    };
  },

  components: {
    ProSelectCity,
  },

  // computed: {},

  mounted() {
    // 初始化客户列表
    this.getAccRelList(1);
    this.initValueIdType();
  },

  methods: {
    async getAccRelList(val) {
      let params;
      if (val == "addcust") {
        params = {
          pageIndex: "1",
          pageSize: "5",
          acctId: this.$route.query.acctId,
          provinceId: this.proSelectVal.proSelect,
          lanId: "",
          provinceAccountId: "",
        };
      } else {
        params = {
          pageIndex: val,
          pageSize: "5",
          acctId: this.$route.query.acctId,
          provinceId: "",
          lanId: "",
          provinceAccountId: "",
        };
      }
      const response = await CreateNewAccountManager.getAccRelList(params);
      if (response.code == 200) {
        this.custArr = response.meta.executeSqlResp;
        this.tablePage = response.meta.pageInfo;
        this.tablePage.pageSize = 5;
        this.custArr.forEach((item) => {
          item.createDate = item.createDate ?
            item.createDate.substring(0, 4) +
            "-" +
            item.createDate.substring(4, 6) +
            "-" +
            item.createDate.substring(6, 8) +
            " " +
            item.createDate.substring(8, 10) +
            ":" +
            item.createDate.substring(10, 12) +
            ":" +
            item.createDate.substring(12, 14) : '';
        });
      }
    },
    async initValueIdType() {
      const response = await CreateNewAccountManager.initValue({
        flag: "cert_type",
      });
      if (response.code == 200) {
        this.idCardList = response.meta.customers;
      }
    },
    digShow() {
      this.outerVisible = true;
       this.queryData1 = {
        proSelect: "", //选择的省
        citySelect: "", //选择的城市
        proId: "", //省客户id
        proAId:"",//省账户id
        provinceAccountNumber:''
      }
    },
    closeShow() {
      this.outerVisible = false;
      this.changeVisible = false;
      this.syncVisible = false;
    },
    returnClick() {
      this.$router.push({
        path: "/custAccountManager",
        query: {
          // partyId: "2102",
          // staffId: "100078",
          // type: "customerAdd",
        },
      });
    },
    // 添加映射关系
    async addCust() {
      let queryData = this.$refs.ProSelectCity.queryData
      let lanId = '';
      if(queryData.proSelect == ''){
        this.$alert('省份:不能为空!','提示',{type:'warning'})
        return
      }
      if(queryData.citySelect == '' &&  queryData.proSelect != "500182716" && queryData.proSelect != "500182954" && queryData.proSelect != "500182957" && queryData.proSelect != "500181505"){
        this.$alert('地市:不能为空!','提示',{type:'warning'})
        return
      }
      if(queryData.citySelect == ''){
        lanId = queryData.proSelect;
      }
      if(queryData.proId == ''){
        this.$alert('省客户ID:不能为空!','提示',{type:'warning'})
        return
      }
      if(queryData.proAId == ''){
        this.$alert('省账户ID:不能为空!','提示',{type:'warning'})
        return
      }
      let params = {
        jtCustNumber: this.$route.query.oldPartyCode,
        custId: this.$route.query.custId,
        provinceId: this.$refs.ProSelectCity.queryData.proSelect,
        lanId: lanId == '' ? this.$refs.ProSelectCity.queryData.citySelect : this.$refs.ProSelectCity.queryData.proSelect,
        provinceAccountId: this.$refs.ProSelectCity.queryData.proAId,
        provinceCustId: this.$refs.ProSelectCity.queryData.proId,
        provinceAccountNumber:this.$refs.ProSelectCity.queryData.provinceAccountNumber,
        staffId: this.$route.query.staffId,
        actType: "ADD",
        acctId: this.$route.query.acctId,
        acctCd: this.$route.query.acctCd,
      };
      const response = await CreateNewAccountManager.accRelMaintain(params);
      if (response.code == 200) {
        this.outerVisible = false;
        this.getAccRelList(1);
      }
    },
    //修改客户信息确定事件
    async jtCustBtn() {
      if(this.changeRowInfo.acctCd == ''){
        this.$alert('集团账户编码:不能为空!','提示',{type:'warning'})
        return
      }
      let params = {
        accountOrmRelId: this.changeRowInfo.accountOrmRelId,
        // custId: "",//手动修改时不传，查询集团客户是传选中的集团客户custId值
        provinceId: this.changeRowInfo.provinceId,
        lanId: this.changeRowInfo.lanId,
        provinceCustId: this.changeRowInfo.provinceCustId,
        provinceAccountId: this.changeRowInfo.provinceAccountId,
        staffId: this.$route.query.staffId,
        actType: "MOD",
        acctCdOld: this.acctCdOld,
        acctCd: this.changeRowInfo.acctCd,
        custId: this.changeRowInfo.custId,
        provinceAccountNumber:this.changeRowInfo.provinceAccountNumber
      };
      const response = await CreateNewAccountManager.accRelMaintain(params);
      if (response.code == 200) {
        if (response.meta.resultCode != 0) {
          this.$alert(response.meta.resultMsg, "提示", { type: "warning" });
        } else {
          this.changeVisible = false;
          this.getAccRelList(1);
        }
      }
    },
    //修改客户关系信息
    handleClick(val) {
      this.changeVisible = true;
      this.jtCustNumberOld = val.jtCustNumber;
      this.changeRowInfo = Object.assign({},val);
      this.acctCdOld = val.acctCd;
    },
    //删除关联客户事件
    delectClick(row) {
      this.$confirm("确认删除该账户关系？", "提示", {
        confirmButtonText: "确定",
        type: "warning",
        cancelButtonText: "取消",
      })
        .then(async () => {
          let params = {
            accountOrmRelId: row.accountOrmRelId,
            custId: this.$route.query.custId,
            provinceId: row.provinceId,
            lanId: row.lanId,
            provinceAccountId: row.provinceAccountId,
            actType: "DEL",
            acctCd: row.acctCd,
            provinceAccountNumber:row.provinceAccountNumber
          };
          const response = await CreateNewAccountManager.accRelMaintain(params);
          if (response.code == 200) {
            this.getAccRelList(1);
          }
        })
        .catch(() => {});
    },
    //切换页码
    pageHandleCurrentChange(val) {
      this.getAccRelList(val);
    },
    //选择证件类型触发事件
    ChangeIdCard(val) {
      
    },
    //查询省账户列表
    async getProAcc(){
       let parmas = {
          custName:this.getProData.custName,
          oldPartyCode:this.getProData.custCode,
          provinceId:this.proSelectVal.proSelect,
          lanId:this.proSelectVal.citySelect,
          provinceAccountId:this.getProData.proAId,
          provinceAccountNumber:this.getProData.proAccCode,
          provinceCustId:this.getProData.proId,
          certType:this.getProData.idType,
          certNum:this.getProData.idNum,
          accNum:this.getProData.proInNum
       }
       const response = await CreateNewAccountManager.getAccProList(parmas);
       if(response.code == 200){
         this.proList = response.meta.customers;
         this.proTablePage.rowCount = response.meta.rowCount
       }
    },
    //查询省客户事件
    checkProAcc() {
      this.proTablePage.pageIndex = 1;
      this.getProAcc()
    },
    //查询集团客户弹窗
    checkCustBtn() {
      this.changeInnerVisible = true;
      this.jtTablePage.pageIndex = 1
      this.getAccountList()
    },
    checkBtn(){
       this.jtTablePage.pageIndex = 1
       this.getAccountList()
    },
    //集团账户列表
    async getAccountList(){
       let parmas = {
         custId:this.$route.query.custId,
         pageIndex:this.jtTablePage.pageIndex,
         pageSize:5,
         acctNameLike:this.getJtData.accName,
         acctCdLike:this.getJtData.accCode,
       }
       const response = await CreateNewAccountManager.getAccountList(parmas);
       if(response.code == 200){
         this.jtList = response.meta.accounts
         this.jtTablePage.rowCount = response.meta.pageInfo.rowCount
         this.jtList.forEach(item=>{
           item.ifDefault = item.ifDefault == 1 ? "是":'否';
           item.createDate = item.createDate ?
            item.createDate.substring(0, 4) +
            "-" +
            item.createDate.substring(4, 6) +
            "-" +
            item.createDate.substring(6, 8) +
            " " +
            item.createDate.substring(8, 10) +
            ":" +
            item.createDate.substring(10, 12) +
            ":" +
            item.createDate.substring(12, 14) : '';
         })
         this.getAccRelList(1)
       }
    },
    //省列表改变当前页触发事件
    proPageChange(val) {
      this.proTablePage.pageIndex = val
      this.getProAcc()
    },
    //集团列表改变当前页触发事件
    jtPageChange(val) {
      this.jtTablePage.pageIndex = val;
      this.getAccountList();
    },
    //点击省账户触发事件
    chooseProAcc(val){
      this.queryData1.provinceAccountNumber = val.PROVINCE_ACCOUNT_NUMBER;
      this.queryData1.proAId = val.PROVINCE_ACCOUNT_ID
      this.queryData1.proId = val.PROVINCE_CUST_ID
      this.innerVisible = false;
    },
    //点击集团账户触发事件
    chooseJtCust(val){
      this.changeRowInfo.acctCd = val.acctCd;
      this.changeInnerVisible = false;
    },
    //自动同步账户到省事件触发
    syncCustPro(){
      this.syncVisible = true
    },
    //同步集团账户到省账户
    async accAutoSynch(){
      let queryData = this.$refs.ProSelectCity.queryData
      let lanId = '';
      if(queryData.proSelect == ''){
        this.$alert('省份:不能为空!','提示',{type:'warning'})
        return
      }
      if(queryData.citySelect == '' &&  queryData.proSelect != "500182716" && queryData.proSelect != "500182954" && queryData.proSelect != "500182957" && queryData.proSelect != "500181505"){
        this.$alert('地市:不能为空!','提示',{type:'warning'})
        return
      }
      if(queryData.citySelect == ''){
        lanId = queryData.proSelect;
      }
      let params = {
        jtCustNumber: this.$route.query.oldPartyCode,   
        custId: this.$route.query.custId,
        provinceId: this.$refs.ProSelectCity.queryData.proSelect,
        lanId: lanId == '' ? this.$refs.ProSelectCity.queryData.citySelect : this.$refs.ProSelectCity.queryData.proSelect,
        staffId: this.$route.query.staffId,
        acctId:this.$route.query.acctId,
        acctCd:this.$route.query.acctCd
      };
      const response = await CreateNewAccountManager.accAutoSynch(params);
      if(response.code == 200) {

      }
    },
    async getCustList(val) {
      let parmas = {
        pageIndex: "1",
        pageSize: "5",
        acctId: this.$route.query.acctId,
        provinceId: val.proSelect,
        lanId: val.citySelect,
        provinceAccountId: val.proAId,
      };
      const response = await CreateNewAccountManager.getAccRelList(parmas);
      if (response.code == 200) {
        this.custArr = response.meta.executeSqlResp;
        this.tablePage = response.meta.pageInfo;
        this.tablePage.pageSize = 5;
      }
    },
    innerDigShow(val) {
      this.getProData = {
        custName: "",
        custCode:"",
        proId: "",
        proAId: "",
        proAccCode:"",
        idType: "",
        idNum: "",
        proInNum: "",
      },
      this.innerVisible = true;
      this.getProData.custName = this.$route.query.custName;
      this.getProData.custCode = this.$route.query.oldPartyCode;
      this.proSelectVal = val;
      this.getProAcc()
    },
  },
};
</script>
<style lang='scss' scoped>
.container {
  height: 100%;
  width: 100%;
  background-color: #fff;
  overflow-x: hidden;
}
.cust-r-title {
  width: 100%;
  padding: 15px 30px;
  .cust-r-l {
    float: left;
    font-size: 15px;
    color: #467cd4;
  }
  .cust-r-c {
    background: #467cd4;
    font-size: 13px;
    color: #fff;
    margin-right: 20px;
    cursor: pointer;
  }
  .cust-r-r {
    font-size: 13px;
    background: #467cd4;
    font-size: 13px;
    color: #fff;
    cursor: pointer;
  }
}
.m-pagination {
  margin-top: 20px;
  margin-right: 100px;
  text-align: right;
}
.btnBox {
  width: 100%;
  text-align: center;
}
.confirmBtn {
  width: 80px;
  background: #467cd4;
  color: #fff;
  margin: 50px 10px 50px 20px;
}
.returnBtn {
  width: 80px;
  color: #fff;
  margin: 10px 0;
}
.checkBtn {
  background: #467cd4;
  color: #fff;
}
// .input-with-select,
// .m-select {
//   width: 100%;
// }
.jt-ipt {
  padding: 0 0.1rem;
}
// .m-contain .el-input {
//     width: 100%;
// }
</style>

